﻿@using Nop.Services.Orders
@model ShoppingCartModel.OrderReviewDataModel
@if (Model.Display)
{
    <div class="order-review-data">
        <div class="billing-info-wrap">
            <div class="billing-info">
                <h2 class="title">
                    @T("Order.BillingAddress")
                </h2>
                <ul class="info-list">
                    <li class="name">
                        @Model.BillingAddress.FirstName @Model.BillingAddress.LastName
                    </li>
                    <li class="email">
                        @T("Order.Email"): @Model.BillingAddress.Email
                    </li>
                    @if (Model.BillingAddress.PhoneEnabled)
                    {
                        <li class="phone">
                            @T("Order.Phone"): @Model.BillingAddress.PhoneNumber
                        </li>
                    }
                    @if (Model.BillingAddress.FaxEnabled)
                    {
                        <li class="fax">
                            @T("Order.Fax"): @Model.BillingAddress.FaxNumber
                        </li>
                    }
                    @if (Model.BillingAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.BillingAddress.Company))
                    {
                        <li class="company">
                            @Model.BillingAddress.Company
                        </li>
                    }
                    @foreach (var item in Model.BillingAddress.AddressFields)
                    {
                        <li class=@item.Key.ToString().ToLower()>@item.Value</li>
                    }

                    @if (!string.IsNullOrEmpty(Model.BillingAddress.FormattedCustomAddressAttributes))
                    {
                        <li class="custom-attributes-view">
                            @Html.Raw(Model.BillingAddress.FormattedCustomAddressAttributes)
                        </li>
                    }
                    @await Html.PartialAsync("_OrderCustomValues", Model.CustomValues?.GetValuesByDisplayLocation(CustomValueDisplayLocation.BillingAddress))
                    @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.OrderSummaryBillingAddress, additionalData = Model })
                </ul>
            </div>
            @if (!string.IsNullOrEmpty(Model.PaymentMethod))
            {
                <div class="payment-method-info">
                    <h2 class="title">
                        @T("Order.Payment")
                    </h2>
                    <ul class="info-list">
                        <li class="payment-method">
                            <span class="label">
                                @T("Order.Payment.Method"):
                            </span>
                            <span class="value">
                                @Model.PaymentMethod
                            </span>
                        </li>
                        @await Html.PartialAsync("_OrderCustomValues", Model.CustomValues?.GetValuesByDisplayLocation(CustomValueDisplayLocation.Payment))
                        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.OrderSummaryPaymentMethodInfo, additionalData = Model })
                    </ul>
                </div>
            }
        </div>

        @if (Model.IsShippable)
        {
            <div class="shipping-info-wrap">
                <div class="shipping-info">
                    <h2 class="title">
                        @(Model.SelectedPickupInStore ? T("Order.PickupAddress") : T("Order.ShippingAddress"))
                    </h2>
                    <ul class="info-list">
                        @if (!Model.SelectedPickupInStore)
                        {
                            <li class="name">
                                @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName
                            </li>
                            <li class="email">
                                @T("Order.Email"): @Model.ShippingAddress.Email
                            </li>
                            if (Model.ShippingAddress.PhoneEnabled)
                            {
                                <li class="phone">
                                    @T("Order.Phone"): @Model.ShippingAddress.PhoneNumber
                                </li>
                            }
                            if (Model.ShippingAddress.FaxEnabled)
                            {
                                <li class="fax">
                                    @T("Order.Fax"): @Model.ShippingAddress.FaxNumber
                                </li>
                            }
                            if (Model.ShippingAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.ShippingAddress.Company))
                            {
                                <li class="company">
                                    @Model.ShippingAddress.Company
                                </li>
                            }
                            @foreach (var item in Model.ShippingAddress.AddressFields)
                            {
                                <li class=@item.Key.ToString().ToLower()>@item.Value</li>
                            }
                            if (!string.IsNullOrEmpty(Model.ShippingAddress.FormattedCustomAddressAttributes))
                            {
                                <li class="custom-attributes-view">
                                    @Html.Raw(Model.ShippingAddress.FormattedCustomAddressAttributes)
                                </li>
                            }
                            @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.OrderSummaryShippingAddress, additionalData = Model })
                        }
                        else
                        {
                            @foreach (var item in Model.PickupAddress.AddressFields)
                            {
                                <li class=@item.Key.ToString().ToLower()>@item.Value</li>
                            }
                        }
                        @await Html.PartialAsync("_OrderCustomValues", Model.CustomValues?.GetValuesByDisplayLocation(CustomValueDisplayLocation.ShippingAddress))
                    </ul>
                </div>
                <div class="shipping-method-info">
                    <h2 class="title">
                        @T("Order.Shipping")
                    </h2>
                    <ul class="info-list">
                        <li class="shipping-method">
                            <span class="label">
                                @T("Order.Shipping.Name"):
                            </span>
                            <span class="value">
                                @Model.ShippingMethod
                            </span>
                        </li>
                        @await Html.PartialAsync("_OrderCustomValues", Model.CustomValues?.GetValuesByDisplayLocation(CustomValueDisplayLocation.Shipping))
                        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.OrderSummaryShippingMethodInfo, additionalData = Model })
                    </ul>
                </div>
            </div>
        }
    </div>
}